package com.tengju.bff.interfaces.covercharge.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tengju.bff.interfaces.covercharge.dto.ChangeProfitDTO;
import com.tengju.bff.interfaces.covercharge.dto.ChangeProfitDetailDTO;
import com.tengju.bff.interfaces.covercharge.dto.QueryAccountReqDTO;
import com.tengju.bff.interfaces.covercharge.dto.ServiceAccountDTO;
import com.tengju.bff.interfaces.covercharge.entity.dto.WithdrawalApplyInfo;
import com.tengju.bff.interfaces.covercharge.entity.po.ServiceAccount;
import com.tengju.bff.interfaces.covercharge.entity.vo.AccountRevisionApplyReqVo;
import com.tengju.bff.interfaces.covercharge.entity.vo.AdminServiceAccountQueryVo;
import com.tengju.bff.interfaces.covercharge.enums.ProfitTypeEnum;
import com.tengju.settlement.domain.model.account.AccountId;
import com.tengju.settlement.domain.shared.Amount;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author fwy
 * @since 2020-02-25
 */
public interface IServiceAccountService extends IService<ServiceAccount> {

    /**
     * 获取收益账户
     *
     * @param accountType 账户类型
     * @param idCode      idCode
     */
    ServiceAccount getAccount(Integer accountType, Integer idCode);

    /**
     * 冻结金额
     *
     * @param accountType 账户类型
     * @param idCode      idCode
     * @param profitType  收益类型
     * @param amount      金额
     * @param bizId       关联表的ID
     */
    void freezeBalance(Integer accountType, Integer idCode, ProfitTypeEnum profitType, BigDecimal amount, Integer bizId, Integer cycleAddId);

    /**
     * 批量解冻金额
     *
     * @param accountType             账户类型
     * @param idCode                  idCode
     * @param profitType              收益类型
     * @param amount                  金额
     * @param withdrawalApplyInfoList 提现申请列表
     */
    void unFreezeBalance(Integer accountType, Integer idCode, ProfitTypeEnum profitType, BigDecimal amount, List<WithdrawalApplyInfo> withdrawalApplyInfoList);

    /**
     * 服务费发放成功修改账户冻结金额
     *
     * @param accountId
     * @param amount
     */
    void updateBalanceForSuccess(Integer accountId, BigDecimal amount, ProfitTypeEnum profitType, Integer bizId, Integer cycleAddId);


    /**
     * 回滚账户冻结金额
     */
    void rollbackFreezeBalance(AccountId accountId, Amount amount, ProfitTypeEnum profitType, Integer bizId, Integer cycleAddId);


    /**
     * 账户增加金额
     */
    void plusBalance(AccountId accountId, Amount amount);


    Page<AdminServiceAccountQueryVo> queryPageByIdCode(Page page, String idCode, String mobile);

    /**
     * 获取账户信息
     *
     * @param req
     */
    List<ServiceAccountDTO> getAccountInfoByIdCodes(QueryAccountReqDTO req);

    /**
     * 获取账户信息
     *
     * @param req
     */
    ServiceAccountDTO batchGetBalanceByIdCodeAndType(QueryAccountReqDTO req);


    /**
     * 处理服务费账户和收益明细
     *
     * @param changeProfit 收益
     * @return 是否成功
     */
    boolean dealServiceAccountAndDetail(ChangeProfitDTO changeProfit);


    /**
     * 根据明细处理服务费账户和收益明细
     *
     * @param changeProfit 收益
     */
    void dealServiceAccountByDetail(String uniqueId,ChangeProfitDetailDTO changeProfit);


    /**
     * 订正账户数据
     * @param req 订正数据
     */
    void revisionAccountData(AccountRevisionApplyReqVo req);


    /**
     * 获取收益账户-若不存在则返回空
     *
     * @param accountType 账户类型
     * @param idCode      idCode
     */
    ServiceAccount judgeAccountExis(Integer accountType, Integer idCode);




}
